package com.zzyl.controller.customer;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.DeviceDto;
import com.zzyl.entity.Device;
import com.zzyl.service.DeviceService;
import com.zzyl.vo.DeviceDataGraphVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(path = "/customer/user")
@Api(tags = "小程序-家属管理")
public class CustomerUserController {
    @Autowired
    private DeviceService  deviceService;

    @PostMapping(path = "/QueryDevicePropertyStatus")
    @ApiOperation("查询产品物模型状态信息")
    public ResponseResult<Map<String,Object>> QueryDevicePropertyStatus(@RequestBody DeviceDto deviceDto){
        Map<String,Object> result=deviceService.queryDevicePropertyStatus(deviceDto);
        return ResponseResult.success(result);
    }

    @GetMapping(path = "/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public ResponseResult<List<DeviceDataGraphVo>> queryDeviceDataListByDay(@RequestParam String iotId,@RequestParam String functionId,@RequestParam Long endTime,@RequestParam Long startTime){
        List<DeviceDataGraphVo> deviceDataGraphVo = deviceService.queryDeviceDataListByDay(iotId,functionId,startTime,endTime);
        return ResponseResult.success(deviceDataGraphVo);
    }

    @GetMapping(path = "/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public ResponseResult<List<DeviceDataGraphVo>> queryDeviceDataListByWeek(@RequestParam String iotId,@RequestParam String functionId,@RequestParam Long endTime,@RequestParam Long startTime){
        List<DeviceDataGraphVo> deviceDataGraphVo = deviceService.queryDeviceDataListByWeek(iotId,functionId,startTime,endTime);
        return ResponseResult.success(deviceDataGraphVo);
    }
}
